<?php

function menu_router(){
    if(isset($_SESSION['permission'])){
        $perm = $_SESSION['permission'];
        if($perm == PERMISSION_USER){
            include_once 'views/menu/menu_user.php';
        } elseif ($perm == PERMISSION_MANAGER) {
            include_once 'views/menu/menu_manager.php';
        } elseif ($perm == PERMISSION_ADMIN) {
            include_once 'views/menu/menu_admin.php';
        } else {
            include_once 'views/menu/menu_sample.php';
        }
    } else {
        $_POST['permission'] = 0;
    }
}


function router()
{
	if(isset($_GET["mod"]))
	{
		if($_GET["mod"] == "admin")
		{
			header("location: index.php");
		}
		else
		{
			if(file_exists("controllers/".$_GET["mod"]."Controller.php"))
			{
				require_once("controllers/".$_GET["mod"]."Controller.php");
			}
			else
			{
				$error = 404;
				require_once("controllers/errorController.php");
			}
		}
	}
	else
	{
		require_once("controllers/publicController.php");
	}
}
?>